package com.cn.qtms.entity;//类注释设置模板

import com.cn.qtms.base.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import java.util.Set;

/**
 * @Name:TmSysResource
 * @Description:
 * @Author: zhangyang
 * @Date: 2019-11-11 13:04
 **/
@Entity
@Table(name = "tm_sys_resource")
@org.hibernate.annotations.Table(appliesTo = "tm_sys_resource",comment="菜单信息表")
@Getter
@Setter
public class TmSysResource extends BaseEntity{

    @Column(name = "parent_id", columnDefinition = "bigint(20) COMMENT '父菜单id'" )
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    @Column(name = "res_code",columnDefinition = "varchar(20) comment '资源代码'")
    private String resCode;

    @Column(name = "res_name", columnDefinition = "varchar(20) comment '资源名称'", unique = true)
    private String resName;

    @Column(name = "res_type", columnDefinition = "varchar(20) comment '资源类型'")
    private String resType;

    @Column(name = "res_path", columnDefinition = "varchar(100) comment '菜单路径'")
    private String resPath;

    @Column(name = "is_leaf", columnDefinition = "bit(1) default 0 comment '是否叶节点'")
    private Boolean isLeaf;

    @Column(name = "se_qu", columnDefinition = "int(5) comment '序号'")
    private Integer seQu;

    @Column(name = "res_level",columnDefinition = "int(5) comment '菜单等级'")
    private Integer resLevel;

    @Column(name = "icon",columnDefinition = "varchar(255) comment '图标'")
    private String icon;


    @JsonIgnore
    @ManyToMany(mappedBy = "tmSysResources")
    private Set<TmSysRole> roles;

    @Override
    public int hashCode() {
        return super.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }
}
